Back to Mono

Caesar Cipher

What is a Caesar Cipher?

Caesar cipher is a substitution cipher that shifts each letter in the plaintext by a fixed number of positions in the alphabet.

Caesar Cipher

How to En\De using Caesar Cipher

Encryption formula:
      E(x) = (x + k) mod 26

Decryption formula:
      D(x) = (x - k) mod 26

Where:
   • x: letter position (A=0, B=1, C=2, ...)
   • k: shift value (key)
   • mod 26: ensures result stays within alphabet range
   • E(x): encrypted letter position
   • D(x): decrypted letter position

Example word "HELLO" with k=3:

• H (position 7):
      E(7) = (7 + 3) mod 26
      = 10 mod 26
      = 10 (letter K)

• E (position 4):
      E(4) = (4 + 3) mod 26
      = 7 mod 26
      = 7 (letter H)

• L (position 11):
      E(11) = (11 + 3) mod 26
      = 14 mod 26
      = 14 (letter O)

• L (position 11):
      E(11) = (11 + 3) mod 26
      = 14 mod 26
      = 14 (letter O)

• O (position 14):
      E(14) = (14 + 3) mod 26
      = 17 mod 26
      = 17 (letter R)

Result: HELLO → KHOOR

Video for explanation